Skip to main content

Controlling the Playlist

Switch music track

Below is an example of how to load a new track when the player collides with a trigger volume.

In the example the track is loaded based on it’s playlist index, but as you can see we can also use the name of the track to load it as well.

[RequireComponent(typeof(BoxCollider))]
public class TrackLoadTrigger : MonoBehaviour
{
[SerializeField] int track;

private void OnTriggerEnter(Collider other)
{
if(track != Reactional.Playback.Playlist.GetSelectedTrack())
{
Reactional.Playback.Playlist.PlayTrack(track);

// Using a name:
Reactional.Playback.Playlist.PlayTrack("MyCoolTrack");
}
}
}